package com.tfswx.jcyw.ruleenginedesigner.api;

import com.tfswx.jcyw.ruleenginedesigner.bean.ApiResult;
import com.tfswx.jcyw.ruleenginedesigner.dto.gzflgl.*;
import com.tfswx.jcyw.ruleenginedesigner.service.GzflService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.NonNull;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Ricky
 * @date 2021/5/11
 */
@RestController
@RequestMapping("/gzflgl")
@Api(tags = "规则分类管理")
public class GzflglController {

    @Resource
    private GzflService gzflService;

    @ApiOperation("获取规则分类列表")
    @PostMapping("/queryGzflListByXmbm")
    public ApiResult<List<GzflListByXmbmQueryOutputDTO>> queryGzflListByXmbm(@NonNull @RequestBody @Validated GzflListByXmbmQueryInputDTO gzflListByXmbmQueryInputDTO) {
        List<GzflListByXmbmQueryOutputDTO> gzflList = gzflService.queryGzflListByXmbm(gzflListByXmbmQueryInputDTO);
        return ApiResult.success(gzflList);
    }

    @ApiOperation("添加规则分类")
    @PostMapping("/addGzfl")
    public ApiResult<String> addGzfl(@NonNull @RequestBody @Validated GzflAddInputDTO gzflAddInputDTO) {
        String gzflbm = gzflService.addGzfl(gzflAddInputDTO);
        return ApiResult.success(gzflbm);
    }

    @ApiOperation("编辑规则分类")
    @PostMapping("/updateGzfl")
    public ApiResult<Boolean> updateGzfl(@NonNull @RequestBody @Validated GzflUpdateInputDTO gzflUpdateInputDTO) {
        boolean isSucc = gzflService.updateGzfl(gzflUpdateInputDTO);
        return ApiResult.success(isSucc);
    }

    @ApiOperation("删除规则分类")
    @PostMapping("/deleteGzfl")
    public ApiResult<Boolean> deleteGzfl(@NonNull @RequestBody @Validated GzflDeleteInputDTO gzflDeleteInputDTO) {
        boolean isSucc = gzflService.deleteGzfl(gzflDeleteInputDTO);
        return ApiResult.success(isSucc);
    }
}
